<template>
  <div class="main-box">
    <div class="empty-box" v-if="showEmpty">暂无数据！</div>
    <div v-else>
      <div
        class="list-item"
        v-for="(item, index) in dailyList"
        :key="index"
        @click="toDailyInfo(item)"
      >
        <div class="title-box">
          <div :class="item.worktype === '远程支持' ? class1 : class2"></div>
          <div class="title-type">{{ item.worktype }}</div>
        </div>
        <div class="info-box">
          <div class="left-box">
            <div>填写人</div>
            <div>提交日期</div>
            <div>工作内容</div>
          </div>
          <div class="right-box">
            <div>{{ item.creator }}</div>
            <div>{{ item.createtime.split("T")[0] }}</div>
            <div>{{ item.workcontent }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    dailyList: {
      type: Array,
      default: null
    },
    openInfoDrawer: {
      type: Function,
      default: null
    }
  },
  watch: {
    dailyList (nv, ov) {
      if (!nv.length) {
        this.showEmpty = true
      } else {
        this.showEmpty = false
      }
    }
  },
  data () {
    return {
      openInfo: true,
      showEmpty: true,
      // 工作类型
      class1: 'title-icon iconfont icon-yuanchengkongzhi',
      class2: 'title-icon iconfont icon-xianchangcaozuo'
    }
  },
  methods: {
    toDailyInfo (row) {
      this.openInfoDrawer(row)
    },
    clickProject (row, column, event) {
      if (!this.openInfo) return
      this.openInfoDrawer(row)
    }
  }
}
</script>

<style lang="scss" scoped>
.main-box {
  height: 91vh;
  padding-top: 10px;
  overflow: auto;

  /* border: 1px solid red; */
  background: #e8e9eb;
  .empty-box {
    width: 100%;
    height: 460px;
    line-height: 460px;
    text-align: center;
  }
  .list-item {
    width: 96%;
    margin-bottom: 10px;
    margin-left: 2%;
    background: #fff;
    border: 1px solid #c4c0c0;
    border-radius: 15px;

    /* background: linear-gradient(#9ccaeb, #cfd5e7); */

    /* background: linear-gradient(50deg, #fff, #cfd5e7, #46a9f0); */
    .title-box {
      /* border: 1px solid red; */
      display: flex;
      height: 40px;
      padding-top: 10px;
      padding-left: 15px;
      line-height: 40px;
      > div {
        font-size: 24px;
      }
      .title-type {
        margin-left: 5px;
      }
    }
    .info-box {
      /* border: 1px solid red; */
      display: flex;
      .left-box,
      .right-box {
        /* border: 1px solid blue; */
        > div {
          display: -webkit-box;
          height: 24px;
          overflow: hidden;
          font-size: 14px;
          line-height: 24px;
          text-overflow: ellipsis;
          -webkit-line-clamp: 1;
          -webkit-box-orient: vertical;
        }
      }
      .left-box {
        width: 25%;
        padding-right: 10px;
        text-align: end;
      }
      .right-box {
        width: 70%;
        text-align: start;
      }
    }
  }
}
</style>